//  XJDCenterFirstFloolView.m
//  XJD
//
//  Created by Angela on 2017/8/25.
//  Copyright © 2017年 Angela. All rights reserved.
//

#import "XJDCenterFirstStoreyView.h"
#define  text98Font  UIColorFromRGB(0x989898)
#define  text62Font  UIColorFromRGB(0x626262)
#define  btnBgColor  UIColorFromRGB(0xf97a2b)
@interface XJDCenterFirstStoreyView()
@property (nonatomic, strong) UIView *fistView;
@property (nonatomic, strong) UIImageView *imgView;
@property (nonatomic, strong) UIView *secondView;
@property (nonatomic, strong) UILabel *borrowMoneylab;//借款金额
@property (nonatomic, strong) UILabel *moneyLab;
@property (nonatomic, strong) UILabel *commissionChargeLab;//手续费用
@property (nonatomic, strong) UILabel *chargeLab;
@property (nonatomic, strong) UILabel *arrivalAmountLab; //到账金额
@property (nonatomic, strong) UILabel *amountLab;

@property (nonatomic, strong) UILabel *arrivalMoneyLab;//到账金额
@property (nonatomic, strong) UIButton *arrivalMoneySMBtn;//到账小金额
@property (nonatomic, strong) UIButton *arrivalMoneyBIGBtn;//到账大金额
@property (nonatomic, strong) UILabel *borrowDayLab;//借款天数
@property (nonatomic, strong) UIButton *borrowDayLessBtn;//借款天数天数短
@property (nonatomic, strong) UIButton *borrowDayMoreBtn;//借款天数大长

@property (nonatomic, strong) UIImageView *redBagImgView;//红包图片
@property (nonatomic, strong) UILabel *inviteWordLab;//邀请好友领红包
@property (nonatomic, strong) UILabel *payMoneyLab;//到期应还
@property (nonatomic, strong) UIButton *nextStepBtn;//下一步

@property (nonatomic, strong) UIView *lastView;
@end
@implementation XJDCenterFirstStoreyView
-(instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        self.frame=rect(0, 0, ScreenWidth, ScreenHeight);
        self.backgroundColor=UIColorFromRGB(0xf2f2f2);
        self.fistView=[[UIView alloc]init];
        self.fistView.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.fistView];
        self.imgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"center_invite _active"]];
        [self.fistView addSubview:self.imgView];
#pragma mark-secondView
        self.secondView=[[UIView alloc]init];
        self.secondView.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.secondView];
        self.borrowMoneylab=[[UILabel alloc]init];
        self.borrowMoneylab.font=[UIFont fontWithName:XJDFont size:realValue6(30)];
        self.borrowMoneylab.textColor=text98Font;
        self.borrowMoneylab.text=@"借款金额";
        [self.secondView addSubview:self.borrowMoneylab];
        self.moneyLab=[[UILabel alloc]init];
        self.moneyLab.font=[UIFont fontWithName:XJDFont size:realValue6(22)];
        self.moneyLab.textColor=text62Font;
        self.moneyLab.text=@"1120元";
        [self.secondView addSubview:self.moneyLab];
        
        self.commissionChargeLab=[[UILabel alloc]init];
        self.commissionChargeLab.font=[UIFont fontWithName:XJDFont size:realValue6(30)];
        self.commissionChargeLab.textColor=text98Font;
        self.commissionChargeLab.text=@"手续费用";
        [self.secondView addSubview:self.commissionChargeLab];
        self.chargeLab=[[UILabel alloc]init];
        self.chargeLab.font=[UIFont fontWithName:XJDFont size:realValue6(22)];
        self.chargeLab.textColor=text62Font;
        self.chargeLab.text=@"120元";
        [self.secondView addSubview:self.chargeLab];
        
        self.arrivalAmountLab=[[UILabel alloc]init];
        self.arrivalAmountLab.font=[UIFont fontWithName:XJDFont size:realValue6(30)];
        self.arrivalAmountLab.textColor=text98Font;
        self.arrivalAmountLab.text=@"到账金额";
        [self.secondView addSubview:self.arrivalAmountLab];
        self.amountLab=[[UILabel alloc]init];
        self.amountLab.font=[UIFont fontWithName:XJDFont size:realValue6(22)];
        self.amountLab.textColor=text62Font;
        self.amountLab.text=@"1000元";
        [self.secondView addSubview:self.amountLab];
#pragma mark-lastView
        self.lastView=[[UIView alloc]init];
        self.lastView.backgroundColor=[UIColor whiteColor];
        [self addSubview:self.lastView];
        
        self.arrivalMoneyLab=[[UILabel alloc]init];
        self.arrivalMoneyLab.font=[UIFont fontWithName:XJDFont size:realValue6(26)];
        self.arrivalMoneyLab.textColor=text62Font;
        self.arrivalMoneyLab.text=@"到账金额";
        [self.lastView addSubview:self.arrivalMoneyLab];
        
        self.arrivalMoneySMBtn=[[UIButton alloc]init];
        [self.arrivalMoneySMBtn setTitleColor:text98Font forState:UIControlStateNormal];
        [self.arrivalMoneySMBtn setTitle:@"500元" forState:UIControlStateNormal];
        self.arrivalMoneySMBtn.layer.cornerRadius=realValue6(20);
        self.arrivalMoneySMBtn.layer.borderWidth=1;
        self.arrivalMoneySMBtn.layer.backgroundColor=text98Font.CGColor;
        self.arrivalMoneySMBtn.backgroundColor=[UIColor whiteColor];
        self.arrivalMoneySMBtn.selected=NO;
        self.arrivalMoneySMBtn.tag=100;
        [self.arrivalMoneySMBtn addTarget:self action:@selector(arrivalMoneyWithborrowDaybtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.lastView addSubview:self.arrivalMoneySMBtn];
        
        
        self.arrivalMoneyBIGBtn=[[UIButton alloc]init];
        [self.arrivalMoneyBIGBtn setTitle:@"10000元" forState:UIControlStateNormal];
        self.arrivalMoneyBIGBtn.layer.cornerRadius=realValue6(20);
        self.arrivalMoneyBIGBtn.layer.borderWidth=1;
        [self.arrivalMoneyBIGBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.arrivalMoneyBIGBtn.layer.borderColor=btnBgColor.CGColor;
        self.arrivalMoneyBIGBtn.backgroundColor=btnBgColor;
        self.arrivalMoneyBIGBtn.selected=YES;
        self.arrivalMoneyBIGBtn.tag=101;
        [self.arrivalMoneyBIGBtn addTarget:self action:@selector(arrivalMoneyWithborrowDaybtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.lastView addSubview:self.arrivalMoneyBIGBtn];
        
        
        self.borrowDayLessBtn=[[UIButton alloc]init];
        [self.borrowDayLessBtn setTitleColor:text98Font forState:UIControlStateNormal];
        [self.borrowDayLessBtn setTitle:@"7天" forState:UIControlStateNormal];
        self.borrowDayLessBtn.layer.cornerRadius=realValue6(20);
        self.borrowDayLessBtn.layer.borderWidth=1;
        self.borrowDayLessBtn.layer.backgroundColor=text98Font.CGColor;
        self.borrowDayLessBtn.backgroundColor=[UIColor whiteColor];
        self.borrowDayLessBtn.selected=NO;
        self.borrowDayLessBtn.tag=102;
        [self.borrowDayLessBtn addTarget:self action:@selector(arrivalMoneyWithborrowDaybtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.lastView addSubview:self.borrowDayLessBtn];
        
        
        self.borrowDayMoreBtn=[[UIButton alloc]init];
        [self.borrowDayMoreBtn setTitle:@"14天" forState:UIControlStateNormal];
        self.borrowDayMoreBtn.layer.cornerRadius=realValue6(20);
        self.borrowDayMoreBtn.layer.borderWidth=1;
        [self.borrowDayMoreBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.borrowDayMoreBtn.layer.borderColor=btnBgColor.CGColor;
        self.borrowDayMoreBtn.backgroundColor=btnBgColor;
        self.borrowDayMoreBtn.selected=YES;
        self.borrowDayMoreBtn.tag=103;
        [self.borrowDayMoreBtn addTarget:self action:@selector(arrivalMoneyWithborrowDaybtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [self.lastView addSubview:self.borrowDayMoreBtn];
        
        
        self.borrowDayLab=[[UILabel alloc]init];
        self.borrowDayLab.font=[UIFont fontWithName:XJDFont size:realValue6(26)];
        self.borrowDayLab.textColor=text62Font;
        self.borrowDayLab.text=@"借款天数";
        [self.lastView addSubview:self.borrowDayLab];
        
        self.redBagImgView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"center_redBag"]];
        [self.lastView addSubview:self.redBagImgView];
        self.inviteWordLab=[[UILabel alloc]init];
        self.inviteWordLab.attributedText=[XJDBaseMethod OneString:@"邀请好友领红包" str1Color:UIColorFromRGB(0xf5a623) str1FontSize:realValue6(28)];
        [self.lastView addSubview:self.inviteWordLab];
        self.payMoneyLab=[[UILabel alloc]init];
        self.payMoneyLab.attributedText=[XJDBaseMethod OneStr:@"到期应还：" str1Color:text98Font str1FontSize:realValue6(30) towStr:@"1120" towStrFontSize:realValue6(40) towStrColor:btnBgColor thirdStr:@" 元" thirdStrColor:text98Font thirdStrFontSize:realValue6(30)];
        self.payMoneyLab.textAlignment=NSTextAlignmentCenter;
        [self.lastView addSubview:self.payMoneyLab];
        self.nextStepBtn=[[UIButton alloc]init];
        [self.nextStepBtn setTitle:@"下一步" forState:UIControlStateNormal];
        self.nextStepBtn.layer.cornerRadius=realValue6(20);
        self.nextStepBtn.layer.borderWidth=1;
        [self.nextStepBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.nextStepBtn.layer.borderColor=btnBgColor.CGColor;
        self.nextStepBtn.backgroundColor=btnBgColor;
        [self.nextStepBtn addTarget:self action:@selector(nextStepButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.lastView addSubview:self.nextStepBtn];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    self.fistView.frame=rect(0,20, ScreenWidth, realValue6(282));
    self.imgView.frame=self.fistView.frame;
    self.secondView.frame=rect(0,self.fistView.bottom+realValue6(18), ScreenWidth, 84);
    self.lastView.frame=rect(0, self.secondView.bottom+realValue6(18), ScreenWidth, ScreenHeight-self.fistView.height-self.secondView.height-realValue6(36));
    [self.borrowMoneylab sizeToFit];
    self.borrowMoneylab.frame=rect(realValue6(60), realValue6(32), _borrowMoneylab.width, _borrowMoneylab.height);
    [self.moneyLab sizeToFit];
    self.moneyLab.frame=rect(0,_borrowMoneylab.bottom+realValue6(26), _moneyLab.width, _moneyLab.height);
    self.moneyLab.centerX=self.borrowMoneylab.centerX;
    
    [self.commissionChargeLab sizeToFit];
    self.commissionChargeLab.frame=rect(0,self.borrowMoneylab.y, _commissionChargeLab.width, _commissionChargeLab.height);
    self.commissionChargeLab.centerX=self.secondView.centerX;
    [self.chargeLab sizeToFit];
    self.chargeLab.frame=rect(0,self.moneyLab.y, _chargeLab.width, _chargeLab.height);
    self.chargeLab.centerX=self.commissionChargeLab.centerX;
    
    [self.arrivalAmountLab sizeToFit];
    self.arrivalAmountLab.frame=rect(ScreenWidth-realValue6(60)-_arrivalAmountLab.width, self.borrowMoneylab.y, _arrivalAmountLab.width, _arrivalAmountLab.height);
    [self.amountLab sizeToFit];
    self.amountLab.frame=rect(0,self.moneyLab.y, _amountLab.width, _amountLab.height);
    self.amountLab.centerX=self.arrivalAmountLab.centerX;
#pragma mark-lastView
    [self.arrivalMoneyLab sizeToFit];
    self.arrivalMoneyLab.frame=rect(realValue6(60), realValue6(72), _arrivalMoneyLab.width, _arrivalMoneyLab.height);
    self.arrivalMoneySMBtn.frame=rect(self.arrivalMoneyLab.right+realValue6(24), 0, realValue6(238), realValue6(64));
    self.arrivalMoneySMBtn.centerY=self.arrivalMoneyLab.centerY;
    self.arrivalMoneyBIGBtn.frame=rect(self.arrivalMoneySMBtn.right+realValue6(20), 0, realValue6(238), realValue6(64));
    self.arrivalMoneyBIGBtn.centerY=self.arrivalMoneyLab.centerY;
    [self.borrowDayLab sizeToFit];
    self.borrowDayLab.frame=rect(self.arrivalMoneyLab.x, self.arrivalMoneyLab.bottom+realValue6(95), _borrowDayLab.width, _borrowDayLab.height);
    self.borrowDayLessBtn.frame=rect(0, 0, realValue6(238), realValue6(64));
    self.borrowDayLessBtn.centerX=self.arrivalMoneySMBtn.centerX;
    self.borrowDayLessBtn.centerY=self.borrowDayLab.centerY;
    self.borrowDayMoreBtn.frame=rect(0, 0, realValue6(238), realValue6(64));
    self.borrowDayMoreBtn.centerX=self.arrivalMoneyBIGBtn.centerX;
    self.borrowDayMoreBtn.centerY=self.borrowDayLab.centerY;
    
    self.redBagImgView.frame=rect(self.borrowDayLab.x,self.borrowDayLessBtn.bottom+realValue6(94),realValue6(60), realValue6(48));
    [self.inviteWordLab sizeToFit];
    self.inviteWordLab.frame=rect(self.redBagImgView.right+realValue6(23), 0, _inviteWordLab.width, _inviteWordLab.height);
    self.inviteWordLab.centerY=self.redBagImgView.centerY;
    
    [self.payMoneyLab sizeToFit];
    self.payMoneyLab.frame=rect(0,self.inviteWordLab.bottom+realValue6(76), ScreenWidth, _payMoneyLab.height);
    self.nextStepBtn.frame=rect(self.borrowDayLab.x, self.payMoneyLab.bottom+realValue6(44),ScreenWidth-self.borrowDayLab.x*2, realValue6(80));
}
-(void)arrivalMoneyWithborrowDaybtnClick:(UIButton *)btn{
    
}
//下一步
-(void)nextStepButton:(UIButton *)btn{
    [self.XJdDelegate nextStepButtonClick:btn];
}
@end
